/*
 * Copyright (C) 2008 Jeffrey Palm.
 *
 * This code is part of the Floto Project (http://jeffpalm.com/floto/).
 * Please consult the LICENSE included in the distribution.
 */
package com.jeffpalm.floto.isight;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;

import javax.swing.JLabel;
import javax.swing.JTextField;

import com.jeffpalm.floto.isight.util.AbstractSplash;

class SplashWindow extends AbstractSplash {
  
  private static final long serialVersionUID = 1L;
  private JTextField status;
  
  SplashWindow() {
    super(newLabel(" floto "));
  }
  
  static JLabel newLabel(String str) {
    JLabel res = new JLabel(str);
    res.setFont(new Font("arial", Font.BOLD, 72));
    return res;
  }
  
  protected void addRest() {
    status = new JTextField("...") {
      private static final long serialVersionUID = 1L;

      protected void paintComponent (Graphics g) {
          Graphics2D g2d = (Graphics2D)g;
          // for antialiasing geometric shapes
          g2d.setRenderingHint( RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON );
    
          // for antialiasing text
          g2d.setRenderingHint( RenderingHints.KEY_TEXT_ANTIALIASING,
                                RenderingHints.VALUE_TEXT_ANTIALIAS_ON );
    
          // to go for quality over speed
          g2d.setRenderingHint( RenderingHints.KEY_RENDERING,
                                RenderingHints.VALUE_RENDER_QUALITY );
    
          super.paintComponent( g2d );
        }
      };
    status.setBackground(Color.white);
    status.setForeground(Color.black);
    status.setBorder(null);
    status.setEditable(false);
    status.setHorizontalAlignment(JTextField.CENTER);
    Font statusFont = new Font("arial", Font.PLAIN, 16);
    status.setFont(statusFont);
    getContentPane().add(status, BorderLayout.SOUTH);
  }

  /**
   * If c isn't null we change the color to that.
   */
  public void setStatus(Object msg, Color c) {
    if (c != null) status.setForeground(c);
    status.setText(String.valueOf(msg));
    status.repaint();
  }

  public void setStatus(Object msg) {setStatus(msg,null);}

}